﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Blizzard.DAL
{
    public interface IDAO
    {

       DataTable GetDataTable(string table, string whereClause);
       DataTable GetDataTable(string table,string identityFieldName, int id);
       DataTable GetManyToManyAssociates(string associateTable, string joinTable, string associatedId, string joinTableAssociateId, string joinTableMainId, int mainObjectId);
       DataTable GetParent(string associateTable, string mainTable, string associateTableIdField, string associateIdFieldInMainTable, string mainTableIdField, int mainObjectId);
       DataTable GetChilderen(string associateTable, string mainTable, string mainTableIdFieldInAssociateTable, string mainTableIdField, int mainObjectId);

        /// <summary>
        /// Persists a many to many relationship by inserting a record into the join table
        /// </summary>
        /// <param name="joinTable"></param>
        /// <param name="fieldNameOne"></param>
        /// <param name="fieldNameTwo"></param>
        /// <param name="filedOneValue"></param>
        /// <param name="fieldTwoValue"></param>
       void JoinTableInserter(string joinTable, string fieldNameOne, string fieldNameTwo, int filedValueOne, int fieldValueTwo);
        /// <summary>
        /// Breaks the many to many relationship by deleting one record from a join table
        /// </summary>
        /// <param name="joinTable"></param>
        /// <param name="fieldNameOne"></param>
        /// <param name="fieldNameTwo"></param>
        /// <param name="filedOneValue"></param>
        /// <param name="fieldTwoValue"></param>
       void JoinTableDeleter(string joinTable, string fieldNameOne, string fieldNameTwo, int filedOneValue, int fieldTwoValue);
        /// <summary>
        /// This method is used for the following two actions:
        /// Breaks a one to many relationship by setting the parentId in child table to zero
        /// Makes a one to many relatinship by setting the parentId to a none zero value
        /// </summary>
        /// <param name="childTable"></param>
        /// <param name="parentIdFieldInChildTable"></param>
        /// <param name="childIdField"></param>
        /// <param name="childId"></param>
       void SetParentId(string childTable, string childIdField, int childId, string parentIdFieldInChildTable, int parentIdValue);

       

       void DeleteRecord(string tableName, string identityFieldName, int identityFieldValue);

       void Insert(string tableName, Dictionary<string, object> fieldValuePairs);
       void Update(string tableName, string identityFieldName , int identityFieldValue, Dictionary<string, object> fieldValuePairs); 

       int GetTheLastInsertedId(string tableName , string identityFieldName);

    }
}
